package com.example.li.service;

import com.example.li.mapper.StatusMapper;
import com.example.li.model.Status;
import com.example.li.util.ResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class StatusService {
    @Autowired
    StatusMapper statusMapper;


    //查询聊天列表service
//    public List getAllStatusList(Status status) {
//        List<Map> maps = statusMapper.selectAllChat(status);
//        return maps;
//    }
    public List getStatusList(Status status) {
        List<Map> maps = statusMapper.chatList(status);
        return maps;
    }


    //    添加聊天信息
    public ResultDTO insertStatus(Status status) {
        status.setTime(new Date());
        int i = statusMapper.insertSelective(status);
        return new ResultDTO().success();
    }

    //管理员删除记录
    public ResultDTO deleteStatus(Status status) {
//        Status status1 = statusMapper.selectByPrimaryKey(status);
        int i = statusMapper.deleteByPrimaryKey(status);
        return new ResultDTO().success();
    }
    //删除消息列表信息
    public ResultDTO deleteChatList(Status status){
          statusMapper.deleteChatList(status);
        return new ResultDTO().success();
    }

    //获取聊天消息列表
    public List<Map> getChatList(Integer id) {

        return statusMapper.getChatList(id);
    }

    public List<Map> getChatList1(Integer id) {

        return statusMapper.getChatList1(id);
    }

    //获取聊天消息数量
    public Integer getChatCount(Integer id) {
        return statusMapper.getChatCount(id);
    }
}
